#include <iostream>
#include <cmath>
#include <unordered_map>
using namespace std;

const int N = 2e5 +10;
unordered_map<long long,long long> mp;

long long n,c,a[N];

int main()
{
	cin >> n; cin >> c;
	for(int i = 1;i <= n; i++)
	{
		cin >> a[i];
		mp[ a[i] ]++;
	}
	long long ret = 0;
	for(int i = 1;i <= n;i++)
	{
		ret += mp[c + a[i]];
	}
	cout << ret << endl;
	return 0;
 } 
